﻿#region License
/* ---------------------------------------------------------------- *
 *
 * This file is part of the Xcoordination Application Space
 * ("XcoAppSpace") http://www.xcoordination.com
 *
 * Copyright (C) 2009 Xcoordination http://www.xcoordination.com
 *
 * XcoAppSpace is free software; you can redistribute it and/or
 * modify it under the terms of version 2 of the GNU General
 * Public License as published by the Free Software Foundation.
 *
 * XcoAppSpace is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/
 * or write to the Free Software Foundation, Inc., 51 Franklin
 * Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 * ---------------------------------------------------------------- */
#endregion

using XcoAppSpaces.Contracts.Service;

namespace XcoAppSpaces.Transport.MSMQ
{
	/// <summary>
    /// Defines extension methods for configuration of an XcoMSMQTransportService using the fluent interface.
	/// </summary>
	public static class FluentConfigExtensions
	{
		/// <summary>
		/// Defines on which queue-name the communication service should be read from.
		/// </summary>
		/// <typeparam name="T">The type of the configuration object.</typeparam>
		/// <param name="config">The configuration object.</param>
		/// <param name="queuename">The queue name on which the communication service should be read from.</param>
		/// <returns>The configuration object for further configuration with the fluent interface.</returns>
        public static T WithQueueName<T>(this IXcoServiceFluentConfiguration<XcoMSMQTransportService, T> config, string queuename)
		{
			config.Service.QueueName = queuename;
			return config.FluentConfig;
		}

		/// <summary>
		/// Defines that the message queue should automatically be removed when the transport service is stopped (meaning when the appspace instance is disposed).
		/// </summary>
		/// <typeparam name="T">The type of the configuration object.</typeparam>
		/// <param name="config">The configuration object.</param>
		/// <returns>The configuration object for further configuration with the fluent interface.</returns>
		public static T WithRemoveQueueOnStop<T>(this IXcoServiceFluentConfiguration<XcoMSMQTransportService, T> config)
		{
			config.Service.RemoveQueueOnStop = true;
			return config.FluentConfig;
		}
	}
}
